
/**
 * Record pre-update trigger.
 * Validate the record to be updated.
 * When false is returned the record will not be updated in the database.
 * When an exception is thrown the record will also not be updated in the database but it will be added to databaseManager.getFailedRecords(),
 * the thrown exception can be retrieved via record.exception.getValue().
 *
 * @param {JSRecord<db:/contable/cuentas>} record record that will be updated
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"8047FD5D-AEED-425C-BE84-D6D12FCFE5A2"}
 */
function onRecordUpdate(record) {
	record.cuenta_busca = 	utils.numberFormat(record.capitulo,"#") + 
	utils.numberFormat(record.subcapitulo,"#" ) + 
	utils.numberFormat(record.rubro,"#") +
    utils.numberFormat(record.cuenta,"0000") + 
    utils.numberFormat(record.subcuenta,"0000");
    
	if (record.subcuenta != 0)
	{
		record.cuenta_formato = utils.numberFormat(record.capitulo,"#")
				+"."+utils.numberFormat(record.subcapitulo,"#")
				+"."+utils.numberFormat(record.rubro,"#")
				+"."+utils.numberFormat(record.cuenta,"0000")
				+" "+utils.numberFormat(record.subcuenta,"0000");
		var texcta = record.subcuentas_to_cuentas.descripcion
		record.cuenta_nueva = utils.numberFormat(record.capitulo,"#")+
				utils.numberFormat(record.subcapitulo,"#")+
				utils.numberFormat(record.rubro,"#")+
				utils.numberFormat(record.cuenta,"0000")+
					utils.numberFormat(record.subcuenta,"0000")+" "+
					utils.stringTrim(texcta) + " - " + record.descripcion;
		record.cuenta_impresion = utils.numberFormat(record.capitulo,"#")+
					utils.numberFormat(record.subcapitulo,"#")+
						utils.numberFormat(record.rubro,"#")+
						utils.numberFormat(record.cuenta,"0000")+" "+
						utils.numberFormat(record.subcuenta,"0000")+" "+
						utils.stringTrim(texcta) + " - " + record.descripcion;
	}
	else
	{
		record.cuenta_formato = utils.numberFormat(record.capitulo,"#")
				+"."+utils.numberFormat(record.subcapitulo,"#")
				+"."+utils.numberFormat(record.rubro,"#")
				+"."+utils.numberFormat(record.cuenta,"0000")
				+ "         " 
		record.cuenta_nueva = utils.numberFormat(record.capitulo,"#")+
				utils.numberFormat(record.subcapitulo,"#")+
					utils.numberFormat(record.rubro,"#")+
					utils.numberFormat(record.cuenta,"0000")
					+"         "+record.descripcion;
		record.cuenta_impresion = utils.numberFormat(record.capitulo,"#")+
					utils.numberFormat(record.subcapitulo,"#")+
						utils.numberFormat(record.rubro,"#")+
						utils.numberFormat(record.cuenta,"0000")+
						"         "+record.descripcion;
	}
return true

}
